package com.jeff.tianti.cms.dao;

import com.jeff.tianti.cms.dto.FriendShipLinkDTO;
import com.jeff.tianti.cms.entity.FriendShipLink;
import com.jeff.tianti.common.dao.CustomBaseSqlDaoImpl;
import com.jeff.tianti.common.entity.PageModel;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

public class FriendShipLinkDaoImpl extends CustomBaseSqlDaoImpl implements FriendShipLinkCustom {
    @Override
    public PageModel<FriendShipLink> queryFriendShipPage(FriendShipLinkDTO friendShipLinkDTO) {
        Map<String,Object> map = new HashMap<String,Object>();
        StringBuilder hql = new StringBuilder();
        hql.append("select t from FriendShipLink t where 1=1 ");
        if(friendShipLinkDTO != null){
            if(StringUtils.isNotBlank(friendShipLinkDTO.getSiteName())){
                hql.append(" and t.siteName like :siteName ");
                map.put("siteName", "%"+friendShipLinkDTO.getSiteName()+"%");
            }
        }
        return this.queryForPageWithParams(hql.toString(),map,friendShipLinkDTO.getCurrentPage(),friendShipLinkDTO.getPageSize());
    }
}
